﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NewsCollection.Common.UpdateGUI
{
    class UpdateButton
    {
        public void UpdateClickStart(Button btnStart, Button btnStop)
        {

            btnStart.Text = "Pause";
           
            btnStop.Enabled = true;
        }
        public delegate void AddCallback(Button btnStart);
        public void UpdateButtonStartAfterRun(Button btnStart)
        {
            if (btnStart.InvokeRequired )
            {
                btnStart.BeginInvoke(new AddCallback(UpdateButtonStartAfterRun),
                    (object) btnStart);
            }
            else
            {




                btnStart.Text = "Start";



            }
            //treeView1.Refresh();

        }
        public void UpdateButtonStopAfterRun(Button btnStop)
        {
            if (btnStop.InvokeRequired)
            {
                btnStop.BeginInvoke(new AddCallback(UpdateButtonStopAfterRun),
                    (object)btnStop);
            }
            else
            {




                btnStop.Enabled = false;



            }
            //treeView1.Refresh();

        }
        public void UpdateAfterRun(Button btnStart, Button btnStop)
        {
            btnStart.Text="Start";
           
            btnStop.Enabled = false;
        }
        public void UpdateClickStop(Button btnStart, Button btnStop,Thread thread)
        {
       //     lv.Clear();
            btnStart.Text = "Start";
            
            btnStop.Enabled = false;
            thread.Abort();
        }
        public void UpdateClickPause(Button btnStart, Button btnStop, Thread thread)
        {
            btnStart.Text = "Continue";
           
            btnStop.Enabled = true;
            thread.Suspend();
        }
        public void UpdateClickContinous(Button btnStart, Button btnStop, Thread thread)
        {
            btnStart.Text = "Pause";

            btnStop.Enabled = true;
            thread.Resume();
        }

    }
}
